﻿using System;
using System.Xml.Linq;
using Microsoft.SilverlightMediaFramework;
using Microsoft.SilverlightMediaFramework.Data;
using Microsoft.SilverlightMediaFramework.Data.Settings;

namespace SMF.HowTo.Data
{
    public class SettingsDataClient : DataClient<SettingsBase>
    {
        public SettingsDataClient(Uri uri)
            : base(uri)
        {
        }

        protected override void OnRequestCompleted(object sender, SimpleEventArgs<string> e)
        {
            try
            {
                XDocument document = XDocument.Parse(e.Result);
                SettingsBase result = SettingsMapper.ParseDocument(document);
                OnFetchCompleted(result);
            }
            catch (Exception err)
            {
                OnFetchFailed(err);
            }
        }
    }
}